def ljust str,len,space = " "
  str = str.to_s
  if str.length > len
    str = str[0..len-1]
  end
  str = str + space*(len-str.length)
end

def rjust str,len,space=" "
  str = str.to_s
  if str.length > len
    str = str[0..len-1]
  end
  str = space*(len-str.length) + str
end

def center str,len,space = " "
  if str.length > len
    str = str[0..len-1]
  end
  llen=len/2
  rlen = len-llen
  cent = ((str.length-1)/2)
  left = str[0..cent]
  right = str[cent+1..str.length-1] 
  rjust(left,llen,space)+ljust(right,rlen,space)
end